/**
 * ControladoraMateria.java
 */

 /**
 *  AdSec: Administrador de Secundarias
 *  Copyright (C) 2009 Daniela Ramírez Chaves (dannyrch@gmail.com)
 *  Copyright (C) 2009 Leonel Salazar Valverde (leo87sv@gmail.com)
 *
 *  This file is part of AdSec.
 *  AdSec is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  AdSec is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with AdSec.  If not, see <http://www.gnu.org/licenses/>.
 */

package adsec.negocios;

import java.util.LinkedList;
import adsec.datos.ControladoraBDMateria;
import adsec.entidades.Materia;
import adsec.entidades.Nivel;


public class ControladoraMateria {

    private ControladoraBDMateria controladoraBDMateria;
    private LinkedList<Materia> listaMaterias;

    public ControladoraMateria(){
        this.controladoraBDMateria = new ControladoraBDMateria();
        this.listaMaterias = new LinkedList<Materia>();
    }//fin de constructor

    public Materia consultarMateria(int idMateria){
        return this.controladoraBDMateria.consultarMateria(idMateria);
    }

    public Materia consultarMateriaGrid(int fila){
        return this.controladoraBDMateria.consultarMateria(this.listaMaterias.get(fila).getIdMateria());
    }

    public LinkedList<Materia> consultarMaterias(){
        this.listaMaterias = this.controladoraBDMateria.consultarMaterias();
        return this.listaMaterias;
    }

    public int insertarMateria(Materia materia, LinkedList<Materia> materiasRequisito){

        return this.controladoraBDMateria.insertarMateria(materia, materiasRequisito);
    }

    public int modificarMateria(Materia materia, LinkedList<Materia> materiasRequisito){
        return this.controladoraBDMateria.modificarMateria(materia, materiasRequisito);
    }

    public int eliminarMateria(int idMateria){
        return this.controladoraBDMateria.eliminarMateria(idMateria);
    }

    public LinkedList<Nivel> consultarNiveles(){
        ControladoraNivel contNivel = new ControladoraNivel();
        return contNivel.consultarNivelesTodos();
    }

    public LinkedList<Materia> consultarMateriasNivel(int nivel){
        return this.controladoraBDMateria.consultarMateriasNivel(nivel);
    }

    public LinkedList<Materia> consultarRequisitosMateria(int idMateria){
        return this.controladoraBDMateria.consultarRequisitosMateria(idMateria);
    }

}//fin de ControladoraMateria
